package com.ysgsignin.wxinfo.common;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author: 叶双贵
 * @version: 1.0
 * @编辑时间：2023/8/28 21:37
 **/
@Configuration
public class FilePathConfig extends WebMvcConfigurerAdapter {

    @Value("${file-save-path}")
    private String fileSavePath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //和页面有关的静态目录都放在项目的static目录下
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");//        registry.addResourceHandler("/uploadPath/**").addResourceLocations("file:/data/uploadPath/drugques/");
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + fileSavePath);
        /**
         * 配置资源映射
         * 意思是：如果访问的资源路径是以“/images/”开头的，
         * 就给我映射到本机的“E:/images/”这个文件夹内，去找你要的资源
         * 注意：E:/images/ 后面的 “/”一定要带上
         */
//        registry.addResourceHandler("/images/**").addResourceLocations("file:E:/shFiles/Student/");
    }

}
